package com.molichuxing.gateway.bff.stock.convertor;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.molichuxing.gateway.bff.stock.entity.response.EntrepotStorageVo;
import com.molichuxing.gateway.bff.stock.entity.response.FenceBaseVo;
import com.molichuxing.gateway.bff.stock.entity.response.StockCarDetailVo;
import com.molichuxing.gateway.bff.stock.entity.response.StockCarVo;
import com.molichuxing.gateway.bff.stock.entity.response.StockRecordBaseVo;
import com.molichuxing.services.business.dto.response.StockCarBizDto;
import com.molichuxing.services.business.dto.response.StockCarDetailDto;
import com.molichuxing.services.business.dto.response.StockRecordBizDto;
import com.molichuxing.services.infrastructure.dto.response.EntrepotStorageDto;
import com.molichuxing.services.infrastructure.dto.response.IovFenceDto;
import com.molichuxing.services.property.StockCarCarStatusEnum;

/**
 * 
 * @author liyg  数据转换
 * 
 */
public class Convert {

	public static StockCarVo toStockCarVo(StockCarBizDto dto) {
		StockCarVo vo=null;
		if(null != dto) {
			vo=new StockCarVo();
			BeanUtils.copyProperties(dto, vo);
		}
		return vo;
	}
	
	public static StockCarDetailVo toStockCarDetailVo(StockCarDetailDto dto) {
		StockCarDetailVo vo=null;
		if(null != dto) {
			vo=new StockCarDetailVo();
			BeanUtils.copyProperties(dto, vo);
			vo.setOperationTime(dto.getStorageTime());
			if(dto.getCarStatus()==3) {
				vo.setCarStatus(StockCarCarStatusEnum.RENTED.getValue());
			}
		}
		return vo;
	}
	
	public static StockCarDetailVo toStockCarDetailVo(StockRecordBizDto dto) {
		StockCarDetailVo vo=null;
		if(null != dto) {
			vo=new StockCarDetailVo();
			BeanUtils.copyProperties(dto, vo);
		}
		return vo;
	}
	
	public static EntrepotStorageVo toEntrepotStorageVo(EntrepotStorageDto dto) {
		EntrepotStorageVo vo=null;
		if(null != dto) {
			vo=new EntrepotStorageVo();
			BeanUtils.copyProperties(dto, vo);
			vo.setStorageId(dto.getId());
		}
		
		return vo;
	}
	
	public static List<EntrepotStorageVo> toEntrepotStorageVoBase(List<EntrepotStorageDto> dtoList) {
		List<EntrepotStorageVo> voList=null;
		if(null != dtoList  && dtoList.size() > 0 ) {
			voList=new ArrayList<>();
			for (EntrepotStorageDto bizDto : dtoList) {
				voList.add(toEntrepotStorageVo(bizDto));
			}
		}
		
		return voList;
	}
	
	public static StockRecordBaseVo toStockRecordBaseVo(StockRecordBizDto dto) {
		StockRecordBaseVo vo=null;
		if(null != dto) {
			vo=new StockRecordBaseVo();
			BeanUtils.copyProperties(dto, vo);
		}
		return vo;
	}
	
	public static FenceBaseVo toFenceBaseVo(IovFenceDto dto) {
		FenceBaseVo vo=null;
		if(null != dto) {
			vo=new FenceBaseVo();
			vo.setFenceId(dto.getId());
			vo.setFenceName(dto.getFenceName());
		}
		return vo;
	}
	
	public static List<FenceBaseVo> toFenceBaseVo(List<IovFenceDto> dtoList) {
		List<FenceBaseVo> voList=null;
		if(null != dtoList  && dtoList.size() > 0 ) {
			voList=new ArrayList<>();
			for (IovFenceDto bizDto : dtoList) {
				voList.add(toFenceBaseVo(bizDto));
			}
		}
		
		return voList;
	}
}
